package com.wang.spring;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

public class SpringDemo01 {

	public static void main(String[] args) throws Exception {
	
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
		
//		Chinese chinese = (Chinese)ctx.getBean("chinese");
//		chinese.setMsg("我是A");
//		chinese.useAxe();
//		System.out.println(chinese.getMsg());
		
		
//		Chinese chinese2 = (Chinese)ctx.getBean("chinese");
//		System.out.println(chinese2.getMsg());
		
//		Customer customer = (Customer)ctx.getBean("customer");
//		System.out.println(customer.getList());
//		System.out.println(customer.getSet());
//		System.out.println(customer.getMap().get("c"));
//		System.out.println(customer.getPros().get("username"));
		
//		Util util = (Util)ctx.getBean("util");
//		System.out.println(util.getDate());
//		DataSource  dataSource = (DataSource)ctx.getBean("dataSource");
//		System.out.println(dataSource.getConnection());
		
//		customer.getPerson().useAxe();
//		Util2 util2 = (Util2)ctx.getBean("util2");
//		System.out.println(util2.getAge());
		
		
//		ServiceImpl service = (ServiceImpl)ctx.getBean("serviceImpl");
//		System.out.println(service.toString());
		
		
		//代理类获取ServiceImpl对象   ProxyFactoryBean
//		ServiceImpl service = (ServiceImpl)ctx.getBean("proxyFactoryBean");
		
//		service.sayHello();
//		service.getDaoMsg();
//		service.getServiceMsg();
		
		//BeanNameAutoProxyCreator
//		ServiceImpl service = (ServiceImpl)ctx.getBean("serviceImpl");
//		service.getDaoMsg();
		
		
		JdbcTemplateDemo jt = (JdbcTemplateDemo)ctx.getBean("jdbcTemplateDemo");
//		jt.query1();
//		jt.query2();
//		System.out.println(jt.findUserByName());
		System.out.println(jt.findAll());
		
		
//		ctx.close();
	}	
	
}










